package com.example.administrator.wallet.view.activity.transaction;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.wallet.R;
import com.example.administrator.wallet.base.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

public class SellActivity extends BaseActivity {

    @Bind(R.id.finish_img)
    ImageButton finishImg;
    @Bind(R.id.view_title)
    TextView viewTitle;
    @Bind(R.id.user_img)
    CircleImageView userImg;
    @Bind(R.id.user_name)
    TextView userName;
    @Bind(R.id.price)
    TextView price;
    @Bind(R.id.price_linear)
    LinearLayout priceLinear;
    @Bind(R.id.user_coin_icon)
    ImageView userCoinIcon;
    @Bind(R.id.rate)
    TextView rate;
    @Bind(R.id.quota_linear)
    LinearLayout quotaLinear;
    @Bind(R.id.counts)
    EditText counts;
    @Bind(R.id.price_money)
    TextView priceMoney;
    @Bind(R.id.trans_linear)
    LinearLayout transLinear;
    @Bind(R.id.select_mode)
    TextView selectMode;
    @Bind(R.id.zhifubao_select)
    ImageView zhifubaoSelect;
    @Bind(R.id.zhifubao)
    LinearLayout zhifubao;
    @Bind(R.id.weixin_select)
    ImageView weixinSelect;
    @Bind(R.id.weixin)
    LinearLayout weixin;
    @Bind(R.id.yinhangka_select)
    ImageView yinhangkaSelect;
    @Bind(R.id.yinhangka)
    LinearLayout yinhangka;
    @Bind(R.id.lists)
    LinearLayout lists;
    @Bind(R.id.total_price)
    TextView totalPrice;
    @Bind(R.id.total)
    LinearLayout total;
    @Bind(R.id.is_release)
    RelativeLayout isRelease;
    @Bind(R.id.activity_sell)
    LinearLayout activitySell;
    @Bind(R.id.sell_submit)
    TextView sellSubmit;

    public static final int ZHIFUBAO = 0;
    public static final int WEIXIN = 1;
    public static final int YINHANGKA = 2;

    @Override
    public void init() {
        initView();
    }

    private void initView() {
        finishImg.setVisibility(View.VISIBLE);
        viewTitle.setText(getString(R.string.sell));
        viewSelected();
        setStatuColor();
    }

    private void viewSelected() {
        zhifubaoSelect.setSelected(false);
        weixinSelect.setSelected(false);
        yinhangkaSelect.setSelected(false);
        payMode(ZHIFUBAO);
    }

    @Override
    public int getLayoutResource() {
        return R.layout.activity_sell;
    }

    @OnClick({R.id.finish_img, R.id.sell_submit, R.id.zhifubao, R.id.weixin, R.id.yinhangka})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.finish_img:
                finish();
                break;
            case R.id.sell_submit:
                break;
            case R.id.zhifubao:
//                hideMoe();
                payMode(ZHIFUBAO);
                break;
            case R.id.weixin:
//                hideMode();
                payMode(WEIXIN);
                break;
            case R.id.yinhangka:
//                hideMode();
                payMode(YINHANGKA);
                break;
        }
    }


    private void payMode(int mode) {
        if (mode == ZHIFUBAO) {
            if (!zhifubaoSelect.isSelected()) {
                zhifubaoSelect.setSelected(true);
                zhifubaoSelect.setVisibility(View.VISIBLE);
            } else {
                zhifubaoSelect.setSelected(false);
                zhifubaoSelect.setVisibility(View.GONE);
            }
        }

        if (mode == WEIXIN) {
            if (!weixinSelect.isSelected()) {
                weixinSelect.setSelected(true);
                weixinSelect.setVisibility(View.VISIBLE);
            } else {
                weixinSelect.setSelected(false);
                weixinSelect.setVisibility(View.GONE);
            }
        }

        if (mode == YINHANGKA) {
            if (!yinhangkaSelect.isSelected()) {
                yinhangkaSelect.setSelected(true);
                yinhangkaSelect.setVisibility(View.VISIBLE);
            } else {
                yinhangkaSelect.setSelected(false);
                yinhangkaSelect.setVisibility(View.GONE);
            }
        }

    }


//    private void hideMode() {
//        yinhangkaSelect.setVisibility(View.GONE);
//        weixinSelect.setVisibility(View.GONE);
//        zhifubaoSelect.setVisibility(View.GONE);
//    }

}
